/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import { page } from "~/question/api/group";
//@ts-ignore
import RemoteSelect from "@/components/ma-remote-select/index.vue";
import { QuestionGroupVo } from "@/modules/question/api/group";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: () => t("question-manage.question"),
      prop: "question",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: t("question-manage.question") }),
      }
    },
    {
      label: () => t("question-manage.group"),
      prop: "group_id",
      render: () => RemoteSelect,
      renderProps: {
        placeholder: t("form.pleaseSelect", { msg: t("question-manage.group") }),
        api: () => new Promise((resolve) => resolve(page({ page_size: 999 }))),
        dataHandle: (response: any) => {
          return response.data.list?.map((item: QuestionGroupVo) => {
            return { label: `${item.name}`, value: item.id };
          });
        },
      },

    },
  ];
}
